home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / DYN401.ZIP / class / lookupky.c < prev    next >
C/C++ Source or Header  |  1997-04-16  |  3KB  |  147 lines

  1.  
  2.  
  3. /*  Copyright (c) 1993-1996 Algorithms Corporation  */
  4. /*  All rights reserved.  */
  5.  
  6.  
  7.  
  8.  
  9. /*  This file automatically generated by dpp - do not edit  */
  10.  
  11. #define    DPP_STRATEGY    2
  12. #define    DPP_FASTWIDE    0
  13.  
  14.  
  15.  
  16.  
  17. #define    CLASS    LookupKey_c
  18. #define    ivType    LookupKey_iv_t
  19.  
  20. #include "generics.h"
  21.  
  22. object    LookupKey_c;
  23.  
  24.  
  25. #line 26 "lookupky.c"
  26. typedef struct  _LookupKey_iv_t  {
  27.     object iKey;
  28. }    LookupKey_iv_t;
  29.  
  30.  
  31.  
  32. #line 19 "lookupky.d"
  33. cmeth objrtn LookupKey_cm_gNewWithObj(object self, object key)
  34.     object luk; 
  35.     ivType *iv; 
  36.  
  37.     ChkArgNul(key, 2); 
  38.     luk = oSuper(LookupKey_c, gNew, self)(self); 
  39.     iv = ivPtr(luk); 
  40.     iv->iKey = key; 
  41.     return luk; 
  42.  
  43. imeth objrtn LookupKey_im_gDeepCopy(object self)
  44. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  45.     object nobj; 
  46.     ivType *niv; 
  47.  
  48.     nobj = oSuper(LookupKey_c, gDeepCopy, self)(self); 
  49.     niv = ivPtr(nobj); 
  50.     if (niv->iKey) 
  51.         niv->iKey = gDeepCopy(iv->iKey); 
  52.     return nobj; 
  53.  
  54. imeth objrtn LookupKey_im_gKey(object self)
  55. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  56.     return iv->iKey; 
  57.  
  58. imeth objrtn LookupKey_im_gChangeKey(object self, object key)
  59. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  60.     object old; 
  61.     ChkArgNul(key, 2); 
  62.     old = iv->iKey; 
  63.     iv->iKey = key; 
  64.     return old; 
  65.  
  66. imeth objrtn LookupKey_im_gDeepDispose(object self)
  67. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  68.     if (iv->iKey) 
  69.         gDeepDispose(iv->iKey); 
  70.     return oSuper(LookupKey_c, gDispose, self)(self); 
  71.  
  72. imeth objrtn LookupKey_im_gStringRepValue(object self)
  73. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  74.     return iv->iKey ? gStringRepValue(iv->iKey) : gNew(String); 
  75.  
  76. imeth int LookupKey_im_gHash(object self)
  77. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  78.     return iv->iKey ? gHash(iv->iKey) : 0; 
  79.  
  80. imeth int LookupKey_im_gCompare(object self, object arg)
  81. { LookupKey_iv_t *iv = GetIVs(LookupKey, self);
  82.     ChkArgNul(arg, 2); 
  83.     if (!iv->iKey && !arg) 
  84.         return 0; 
  85.     if (!iv->iKey) 
  86.         return -1; 
  87.     if (!arg) 
  88.         return 1; 
  89.     return gCompare(iv->iKey, gKey(arg)); 
  90.  
  91.  
  92. #line 102 "lookupky.c"
  93.  
  94. objrtn    LookupKey_initialize(void)
  95. {
  96.     static  CRITICALSECTION  cs;
  97.     static  int volatile once = 0;
  98.  
  99.     ENTERCRITICALSECTION(_CI_CS_);
  100.     if (!once) {
  101.         INITIALIZECRITICALSECTION(cs);
  102.         once = 1;
  103.     }
  104.     LEAVECRITICALSECTION(_CI_CS_);
  105.  
  106.     ENTERCRITICALSECTION(cs);
  107.  
  108.     if (LookupKey_c) {
  109.         LEAVECRITICALSECTION(cs);
  110.         return LookupKey_c;
  111.     }
  112.     INHIBIT_THREADER;
  113.     Association_initialize();
  114.     if (LookupKey_c)  {
  115.         ENABLE_THREADER;
  116.         LEAVECRITICALSECTION(cs);
  117.         return LookupKey_c;
  118.     }
  119.     LookupKey_c = gNewClass(Class, "LookupKey", sizeof(LookupKey_iv_t), 0, Association, END);
  120.     cMethodFor(LookupKey, gNewWithObj, LookupKey_cm_gNewWithObj);
  121.     iMethodFor(LookupKey, gCompare, LookupKey_im_gCompare);
  122.     iMethodFor(LookupKey, gChangeKey, LookupKey_im_gChangeKey);
  123.     iMethodFor(LookupKey, gKey, LookupKey_im_gKey);
  124.     iMethodFor(LookupKey, gStringRepValue, LookupKey_im_gStringRepValue);
  125.     iMethodFor(LookupKey, gHash, LookupKey_im_gHash);
  126.     iMethodFor(LookupKey, gDeepDispose, LookupKey_im_gDeepDispose);
  127.     iMethodFor(LookupKey, gDeepCopy, LookupKey_im_gDeepCopy);
  128.  
  129.     ENABLE_THREADER;
  130.  
  131.     LEAVECRITICALSECTION(cs);
  132.  
  133.     return LookupKey_c;
  134. }
  135.  
  136.  
  137.  
  138.